|
Table of Contents
NOTE: you can find this and other lessons in a
more complete and viewable format (including all Figures) in our Tutorial PDF.
Lesson 9. How to Specify the Sort Order and Control Breaks
-
This lesson teaches you how to sort your report into the order you want. It also explains how to add control breaks to your report. And it shows how to use control breaks to create summary reports. The control statements discussed are:
-
the
SORT
statement
-
the
BREAK
statement
-
the
SUMMARY
parm of the
OPTIONS
statement
How to Use the SORT Statement
-
When no
SORT
statement is specified, Spectrum SMF Writer defaults to printing the report records in their original input file order. For SMF files, that is normally the order in which the records were logged by the SMF system. The sample SMF reports in the previous lessons all appeared in this default order.
-
To print a report in a different order, just add a
SORT
statement. The
SORT
statement can appear anywhere after the
INPUT
statement. Only one
SORT
statement is allowed per report, but it may contain as many "sort fields" as you like. Spectrum SMF Writer will sort your report on all of the sort fields.
-
For example, let's request a report from the
SMF14
records and sort it on two fields:
SORT: SMF14_JOBID SMF14EXCP(D)
-
Now the report will be sorted first on
SMF14-JOBID
. That is a computed field that was discussed on Here is an example of a character field that is handy for reports from many SMF record types, including type 14.. It has a unique value for each job in the SMF file. When the file has multiple
SMF14
records for the same job, then those records will be sorted in descending
SMF14EXCP
order.
-
The report in Figure _ uses the above statement.
Using a
SORT
statement to specify the sort order of a report
Using a SORT statement to specify the sort order of a report
|
-
you can actually use the
SMF14_JOBID
in your own reports without even having to write a
COMPUTE
statement for it. This field is so useful that we have included the
COMPUTE
statement for it right in the copy library.
-
The
SORT
statement can name any field in the input file (as well as any
COMPUTE
field). You are not limited to just the fields that are listed in the
COLUMNS
statement.
-
You may also put a trailing
#EQUAL
parm after all of the sort fields. That parm causes "tie" records to remain in their original relative order.
-
By default, Spectrum SMF Writer sorts reports into ascending order on each sort field. If you want to sort the report into descending order for a field, put the
DESCENDING
parm (or just
DESC
or
D
) in parentheses immediately after the field name.
How to Use the BREAK Statement
-
Consider the result of sorting the report in Figure _ on the
SMF14-JOBID
field. As you can see, it causes all of the records for a given job to be grouped together.
-
Often it is desirable to perform special processing whenever one such group of records ends and another group is about to begin. For example, you might want to print a line of totals for the group (the job, in this case) that just ended. Or, you might want to print a few blank lines before the next group starts printing, or even skip to a new page. This processing is called control break processing.
-
A control break occurs whenever one group of records ends and another group is about to begin. The field that is being grouped (for example,
SMF14
-
JOBID
) is called the control break field. A control break field must also be a sort field, since it is by being sorted that records are grouped together in the first place.
-
You may designate any sort field as a control break field. Just name the field in a
BREAK
statement:
SORT: SMF14-JOBID SMF14EXCP(D)
BREAK: SMF14-JOBID
-
The above statements make
SMF14-JOBID
a control break field (as well as a sort field). Now we will get job totals in the report whenever the lines for one job ends and another job is about to begin.
-
After the totals, two blank lines will print. Then the report lines for the next job start to print, and so on.
-
Figure _ shows a report that uses the above
BREAK
statement to produce a control break. Notice that at the breaks (by default) Spectrum SMF Writer prints: the value of the break field, the number of item in the control group, and totals for each numeric column. It also indicates the level of the break with a number of leading asterisks.
Using the
BREAK
statement to create a control break
Using the BREAK statement to create a control break
|
Control Break Spacing
-
You can use additional parms in the
BREAK
statement to customize your control break. For example, you can specify a break spacing parm. This parm tells Spectrum SMF Writer what kind of spacing to perform at the control break. By default, Spectrum SMF Writer prints two blank lines at each control break (after the totals line). Use a spacing parm to request either a different number of blank lines, or to request a page break.
-
For example, the following statement makes
SMF14-JOBID
a break field and specifies that 3 blank lines should print at the control break:
BREAK: SFM14-JOBID SPACE(3)
-
If you want to skip to a new page whenever the contents of a field changes, use the
PAGE
spacing parm, like this:
BREAK: SMF14SID SPACE(PAGE)
-
The
SPACE(PAGE)
parm specifies that, rather than printing 2 blank lines whenever the
SMF14SID
field (the System Identification) changes, the report should skip to a new page.
-
you can also specify the
NOTOTALS
parm on the
BREAK
statement, if you only want blank lines or a new page at the break, and do not also want totals:
BREAK: SMF14SID NOTOTALS
How to Create a Summary Report
-
A summary report is one which does not show the detail information for every record included in the report. Instead the detail information is summarized and only the totals are printed in the report.
-
Control breaks are used to create the desired total lines. Consider again the report in Figure _. It is a detail report that lists the
EXCP
count for every
DDNAME
accessed by a job in the SMF file. The control break on
SMF14-JOBID
causes a total line to print after the detail lines for each job. By just adding the following statement, we can suppress the detail lines and print only those job totals:
OPTIONS: SUMMARY
-
Figure _ shows a summary report that uses the above statement. This report just shows the total
EXCP
count for each job.
Using the
SUMMARY
option to make a summary report
Using the SUMMARY option to make a summary report
|
-
if we intended to use this report as something more than a one-shot job, we would make some changes to improve its appearance. We could remove some or all of the character columns, since those fields are empty in the total lines.
-
But for this example, we wanted to clearly demonstrate that any report that has a control break can easily be turned into a summary report -- just by adding one option to it.
Multiple Control Breaks
-
You may designate more than one sort field as a control break field. Use a separate
BREAK
statement for each sort field that you want to break on.
-
Consider these control statements:
COMPUTE: SMF14_TIMESTAMP = #FORMAT(SMF14RSD) + ' ' + #FORMAT(SMF14RST)
*
SORT: SMF14JBN SMF14_TIMESTAMP SMF14EXCP(D)
BREAK: SMF14JBN SPACE(3)
BREAK: SMF14_TIMESTAMP SPACE(1)
-
In this example, we have, in effect, split the
SMF14_JOBID
field into two components: the jobname alone (
SMF14JBN
), and the reader start date/time in a separate field (
SMF14-TIMESTAMP
). By sorting on both of these fields (plus
SMF30EXCP
as the tie breaker), our report remains in the same order as in the previous example.
A report with nested control breaks
A report with nested control breaks
|
-
But now we can break separately on two occasions. First we can break, as before, when each individual job ends and show its
EXCP
total. The break on
SMF14_TIMESTAMP
does that for us. That break's total line is followed by 1 blank line.
-
And now we can have an additional break each time the jobname alone changes. The totals at that break will include all runs of a job with that name in the SMF file. The jobname break is followed by 3 blank lines.
-
Notice that the number of asterisks in the default total lines serves as a visual indicator of the level of the break.
-
All
BREAK
statements must appear after the
SORT
statement.
-
When multiple
BREAK
statements are used, the
BREAK
statements may appear in any order. Note that the order of the
BREAK
statements does not determine which break is nested within the other. That is determined by the order of the fields in the
SORT
statement.
Summary
-
Here is a summary of what we learned in this lesson:
-
use the
SORT
statement to sort your report
-
you can sort on multiple sort fields
-
you can sort in either ascending or descending order
-
use the
BREAK
statement to specify a control break field
-
control break fields must also be sort fields
-
use the
SPACE
parm to specify your own spacing at the control break
-
you can specify multiple control breaks in the same report
-
The next lesson will show you how to print statistics at control breaks, and how to write your own custom lines at the beginning and end of a control group.
To Learn More
-
You can also learn how to:
-
create a control break with the
SORT
statement
-
specify control break spacing with the
SORT
statement
-
request totals and statistics in the
SORT
statement
-
use additional control break spacing parms, including one that skips to a new sheet of paper
-
compute percentages and ratios that apply to an entire control group
-
create multiple levels of summarization
-
the complete syntax for the
SORT
and
BREAK
statements is given in and
NEXT LESSON: Customizing the Control Breaks
|